import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;


public class ArrayGetter {
	public static Integer[] getIntegerArray(String fileName){
		ArrayList<Integer> temp = new ArrayList<Integer>();
		BufferedReader myReader = null;
		try {
			myReader = new BufferedReader(new FileReader(fileName));
			for(String currLine = myReader.readLine();currLine!=null;currLine = myReader.readLine()){
				String[] nums = currLine.split(" ");
				for(int i=0;i<nums.length;i++){
					temp.add(Integer.valueOf(nums[i]));
				}
			}
			
			Integer[] toReturn = new Integer[temp.size()];
			temp.toArray(toReturn);			
			
			return toReturn;
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (NumberFormatException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			try {
				if(myReader!=null){
					myReader.close();
				}
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		return null;
	}	
	
	public static String getPrintedContents(Object[] array){
		String toReturn = new String();
		for(int i=0;i<array.length;i++){
			if(array[i] == null){
				break;
			}
			toReturn += array[i] + " ";
		}
		return toReturn;
	}
}
